#include<iostream>
#include <vector>

using namespace std;

int main( )
{
    string str;
    cout << "please input string :"  << endl;
    cin >> str;
    string targetStr = "matiji";
    int targetStrLen=targetStr.length();
    int ans = 0;
    // 遍历整个给定的字符串
    for (int i = 0; i <= str.length() - 6; i++)
    {
        if (str.substr(i, targetStrLen) == targetStr)
        {
            ans++;
        }     
    }
    cout << ans;
    return 0;
}